/*
 * WeatherSession.cpp
 *
 *  Created on: Apr 13, 2010
 *      Author: songyp
 */

#include "WeatherSession.h"
#include "WeatherProtocol.h"
#include <WeatherAndCity.h>

#include <e32debug.h>

CWeatherSession::CWeatherSession()
	{
	
	}

CWeatherSession::~CWeatherSession()
	{
	
	}

CWeatherSession * CWeatherSession::NewL()
	{
	CWeatherSession * self = new (ELeave) CWeatherSession;
	CleanupStack::PushL( self );
	self->ConstructL();
	CleanupStack::Pop();
	return self;
	}

void CWeatherSession::ConstructL()
	{
	
	}

void CWeatherSession::ServiceL( const RMessage2 &aMessage )
	{
	switch( aMessage.Function() )
		{
		case EGetWeather:
			TInt city = aMessage.Int0();
			TInt weather = -1;
			
			if( EBeijing == city )
				weather = ESunny;
			else if( EShenyang == city )
				weather = ECloudy;
			TPckg<TInt> data( weather );
			aMessage.WriteL( 1, data );
			aMessage.Complete( KErrNone );
			break;
		default:
			aMessage.Complete( -1 );
			break;
		}	
	}

